<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>学号绑定</title>
    <link href="https://cdn.bootcss.com/weui/1.1.2/style/weui.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/2.1.4/jquery.js"></script>
	{css href="/public/layer/need/layer.css" /}
	{js href="/public/layer/layer.js" /}
</head>
<body>
<div class="weui-cells__title">默认密码为:111,密码不正确请联系辅导员教务处找回哟<br/>解绑回复【重置】</div>
<div id="first" style="display: block">
    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="text" name='name' id="name" placeholder="请输入您的姓名">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">学号</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="tel" name="xuehao" id="xuehao" placeholder="学号">
            </div>
            
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">密码</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="password" name="mima" id="mima" placeholder="密码，默认：111">
            </div>
            
        </div>
    </div>
    <div class="weui-btn-area">
        <a class="weui-btn weui-btn_primary" href="javascript:" id="showTooltips">绑定</a>
    </div>
</div>

</body>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
 <script>
	wx.config({
      debug:true,
      appId: "{$getSignPackage['appId']}",
      timestamp: "{$getSignPackage['timestamp']}",
      nonceStr: "{$getSignPackage['nonceStr']}",
      signature: "{$getSignPackage['signature']}",
      jsApiList: [
      
        'closeWindow',
        'onMenuShareTimeline',
        'onMenuShareAppMessage'
      ]
    });
    wx.ready(function() {

    });

    function closeWindow() {
       wx.closeWindow();
    }

    wx.error(function(res) {
        alert(res.errMsg);
    });
	function msg(msg){
		
		layer.open({
		    content: msg
		    ,skin: 'msg'
		    ,time: 2 //2秒后自动关闭
		  });
	
	}

	function loading () {
		layer.open({
		    type: 2
		    ,content: '加载中'
		  });
	}

	function closeAll () {
			
		setTimeout(function(){

			layer.closeAll()
						
		}, 2000 );
	}
	$("#showTooltips").click(function(){
		
		if($("#name").val()==''){
			msg('请输入姓名');
			$("#name").focus();
			return false;
			}
		else if($("#xuehao").val()==''){
			msg('请输入学号');
			$("#xuehao").focus();
			return false;
		}
		else if ($("#mima").val()==''){
			msg('请输入密码');
			$("#mima").focus();
			return false;
		}
		var name=$("#name").val();
		var xuehao=$("#xuehao").val();
		var mima=$("#mima").val();
		loading();
		$.ajax({
				type: 'post',
				url: '{:url('index')}',
				data: {
					name:name,
					xuehao:xuehao,
					mima:mima
				}, success: function (res) {
					
					if(res.status == 1){
						msg(res.msg);
						closeAll();
						setTimeout(function(){
							closeWindow();
						}, 2000 );	

					}else{
						msg(res.msg);
						closeAll();
					}	
					
				}, error: function (res) {
					
					msg('网络错误,稍后再试！');
					closeAll();
				   
				}
        });
		
	})
  
  </script>